// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (c) 2023 Yevhen Babiichuk (DustDFG)

#ifndef _VIEW_TUBE_HPP_
#define _VIEW_TUBE_HPP_

#include <cstdint>
#include <vector>

#include <SFML/Graphics.hpp>
#include <SFML/Graphics/Drawable.hpp>

#include <Abracadabra/View/Theme.hpp>

namespace View
{

class Tube
{
	private:
		uint8_t size;

		sf::FloatRect boundsRect;

		Theme* theme;

		std::vector<sf::RectangleShape> dots;
		std::vector<sf::RectangleShape> tube;
		std::vector<sf::RectangleShape> selectedTube;

		sf::FloatRect getSlotRect(uint8_t slotIndex) const;
		sf::FloatRect getOverflowRect() const;

	public:
		Tube(uint8_t size, sf::FloatRect boundsRect, Theme* theme);

		void update(const std::vector<uint8_t>& dots);

		bool contains(sf::Vector2f position);

		void drawDots(sf::RenderTarget& target) const;
		void drawTube(sf::RenderTarget& target) const;
		void drawSelectedTube(sf::RenderTarget& target) const;
};

}

#endif
